k,b,n,t = map(int, raw_input().split())

sec = 0
zi = 1
while(zi<t):
	sec += 1
	zi = zi * k + b

if sec>n : print 0
elif zi==t: print n-sec
else: print n-sec+1
